<?php
namespace frontend\helpers;

class SwiperHelper
{
    public static function generateWithNavigation($bucketName, $prevStr, $galleryStr)
    {
        $generatedStr = '';

        if($galleryStr != '')
        {
            $generatedStr .= '<div class="swiper-container">
            <div class="swiper-wrapper">';

            if($prevStr != '')
            {
                $generatedStr .= '<div class="swiper-slide"><img src="https://storage.yandexcloud.net/' . $bucketName . '/' . $prevStr . '"></div>';
            }
            
            foreach(explode(',', $galleryStr) as $image)
            {
                $generatedStr .= '<div class="swiper-slide"><img src="https://storage.yandexcloud.net/' . $bucketName . '/' . $image . '"></div>';
            }
            
            $generatedStr .= '</div>
            </div>
            <div class="slider-button-prev"></div>
            <div class="slider-button-next"></div>
            ';

        }
        else if($prevStr != '')
        {
            $generatedStr .= '<img src="https://storage.yandexcloud.net/' . $bucketName . '/' . $prevStr . '">';
        }

        return $generatedStr;
    }
}